#!/usr/bin/python
# -*- coding: UTF-8 -*-

from kpautos.engine.case import Case
from kptest.config.enum import DeviceType, HostType, DeviceUtility


class BMC_IPMI_02(Case):
    """
        Name:
            BMC_IPMI_02
        Label:
            传感器数值检查
        PreCondition:
            1、BMC正常运行
        TestStep:
            1、带外执行ipmitool sensor list命令读取传感器数值
        ExpectedResult:
            A) 传感器数值正常显示
        Parameters:

        Remark:

    """

    # 测试执行前配置等准备操作
    def pre_test_case(self):
        self.device_dut = self.resource.get_device(device_type=DeviceType.Server, utility=DeviceUtility.DUT)
        self.os_host = self.device_dut.get_host(host_type=HostType.HostOS)
        self.cli_api = self.device_dut.get_api(ns_name="BmcCli")
        self.ipmi_api = self.device_dut.get_api(ns_name="Ipmi")

    # 测试步骤
    def procedure(self):
        self.log_step("1、带外执行ipmitool sensor list命令，读取传感器数值")
        fru_info = self.ipmi_api.ipmi_get_sensor_list()
        if fru_info == None:
            raise Exception("带外读取传感器数值失败")

    # 测试结束后恢复环境
    def post_test_case(self):
        pass